import React from 'react'
import PropTypes from 'prop-types'
import {Link} from 'react-router-dom'
import {Table} from 'antd'
import AnimTableBody from 'components/DataTable/AnimTableBody'
import styles from './List.less'
import classnames from 'classnames'

const List = ({
                isMotion, location, ...tableProps
              }) => {
  const columns = [
    {
      title: '文本内容',
      dataIndex: 'textContent',
      key: 'textContent',
      render: val => val ? val : '图片/视频内容',
    }, {
      title: '图片视频链接内容',
      dataIndex: 'mediaContent',
      key: 'mediaContent',
      render: () => <Link to={''}>详情</Link>,
    }, {
      title: '地理位置',
      dataIndex: 'geoLocation',
      key: 'geoLocation',
      render: val => val ? val : '-',
    }, {
      title: '发布时间',
      dataIndex: 'releaseTime',
      key: 'releaseTime',
    },
  ]

  const AnimateBody = (props) => {
    return <AnimTableBody {...props} />
  }

  const CommonBody = (props) => {
    return <tbody {...props} />
  }

  return (
    <Table
      {...tableProps}
      className={classnames(styles.table, {[styles.motion]: isMotion})}
      columns={columns}
      simple
      rowKey={record => record.id}
      components={{
        body: {wrapper: isMotion ? AnimateBody : CommonBody},
      }}
    />
  )
}

List.propTypes = {
  isMotion: PropTypes.bool,
  location: PropTypes.object,
}

export default List
